﻿using System;
using System.Collections;
using System.Configuration;
using System.Web.Configuration;
using HospitalSystem.Core;
using System.Data.SqlClient;
namespace HospitalSystem
{
    public partial class Groups : System.Web.UI.Page
    {

        private GroupsLog _group;
        protected void Page_Load(object sender, EventArgs e)
        {

            _group = new GroupsLog();
            if (!IsPostBack)
            {
                findstaffID();
                _group.BindData(GridView4);
                _group.crepsnumber(HostID,StaffID);
                _group.psnumbertolabel(psnumber);
                Session["PSNumber01"] = psnumber.Text;
                
               }

        }
      
       

        protected void Button1_Click(object sender, EventArgs e)
        {


            _group.inserttoServiceProvisionVsPerson(GridView4,SelectStat,psnumber);

            Response.Redirect("~/servicerecord2.aspx");

        }

        protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void GridView2_SelectedIndexChanged1(object sender, EventArgs e)
        {

        }




        protected void findstaffID()
        {



            string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
            SqlConnection conn = new SqlConnection(constr);

            SqlCommand CmdSql2 = new SqlCommand("SELECT Staff_id FROM [Employee] where Username=@Username", conn);
            conn.Open();
            CmdSql2.Parameters.AddWithValue("@Username", Session["idlogin"]);

            SqlDataReader reader2 = CmdSql2.ExecuteReader();



            if (reader2.Read())
            {
                StaffID.Text = reader2["Staff_id"].ToString();


            }
            else
            {

            }
            conn.Close();
            reader2.Close();

        }


    }
}